#define quickread
#ifdef quickread
#include <cstdio> 
template <typename T>
inline void read(T& x)
{
    int c=getchar(), f=1; x=0;
    while(c<'0'||'9'<c) {if(c=='-') f=-1; c=getchar();}
    while('0'<=c&&c<='9') 
        x=(x<<3)+(x<<1)+c-'0', c=getchar();
    x*=f;
}
template <typename T>
inline void quickwrite(T x)
{
    if(x<0) putchar('-'), x*=-1;
    if(x>=10) quickwrite(x/10);
    putchar(x%10+'0');
}
#else 
#include <iostream>
#endif
#include <cstring>
#include <vector>
#include <algorithm>
using namespace std;
using ll=long long;
#define DEBUG
const int N=1e6+10, M=N<<1;
int h[N], w[M], e[M], ne[M], idx;

int n, m;
ll dp[N]; //dp[u]:以u为根的子树个数(删除u后的连通块个数)
int blocksz[N]; //u所在连通块的最大节点数

void AddEdge(int a, int b)
{
    e[idx]=b, ne[idx]=h[a], h[a]=idx++; 
}

void init()
{
    idx=0;
    memset(h, -1, sizeof h);
    read(n), read(m);
    for(int i=1; i<n; i++)
    {
        int a, b; read(a), read(b);
        AddEdge(a, b); AddEdge(b, a);
    }
}

void dfs(int u, int fa)
{
    vector<pair<int, int>> son; //子树的大小 子树连通块个数
    for(int i=h[u]; ~i; i=ne[i])
    {
        int v=e[i];
        if(v==fa) continue;
        dfs(v, u);
        son.push_back({blocksz[v], dp[v]});
    }

    if(son.empty()) { //叶子节点
        blocksz[u]=1;
        dp[u]=1; //自身为连通块唯一节点
        return;
    }

    sort(son.begin(), son.end()); //按子树大小排序，优先合并小连通块

    int tree_count=0; //可合并的子树个数
    ll node_count=0; //合并的子树节点总数，不包含u本身
    while(tree_count<son.size() && node_count+son[tree_count].first<=m-1)
    {
        node_count+=son[tree_count].first; //累加子树节点数
        tree_count++; //合并子树个数
    }

    //计算u的连通块信息
    blocksz[u]=node_count+1; //子树总节点数+根节点
    dp[u]=1; //u自身为连通块
    
    //合并前treesum格子节点的连通块
    for(int i=0; i<tree_count; i++)
        dp[u]+=son[i].second-1; //每个子树块贡献(子块数-1)个连通块

    //不能合并的直接累加
    for(int i=tree_count; i<son.size(); i++)
        dp[u]+=son[i].second;     
}

void solve()
{
    init();
    dfs(1, 0);
    quickwrite(dp[1]); puts("");
}

// #undef DEBUG
signed main()
{
    #ifdef DEBUG
        freopen("./in.txt", "r", stdin);
        // freopen("./out.txt", "w", stdout);
    #endif
    #ifndef quickread
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    #endif

    int T=1; //scanf("%d", &T);
    while(T--) 
    {
        solve();
    }
    return 0;
}
